//
//  MainTabbar.m
//  sinaWeiBo
//
//  Created by feng on 16/9/3.
//  Copyright © 2016年 feng. All rights reserved.
//

#import "MainTabbar.h"
@interface MainTabbar ()


@end
@implementation MainTabbar
- (UIButton *)plusBtn{

    if (_plusBtn==nil) {
        _plusBtn=[UIButton new];
        [_plusBtn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
        [_plusBtn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateHighlighted];
        [_plusBtn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
        [_plusBtn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateHighlighted];
        [self addSubview:_plusBtn];
    }

    return _plusBtn;

}

- (void)layoutSubviews{

    [super layoutSubviews];
    CGFloat w=self.bounds.size.width/5;
    CGFloat h=self.bounds.size.height;
    CGRect rect=CGRectMake(0,0,w,h);
    int index=0;
    for (UIView *subView in self.subviews) {
        if ([subView isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
            subView.frame=CGRectOffset(rect, w*index, 0);
            index+=(index==1?2:1);
        }
    }

    _plusBtn.frame=CGRectOffset(rect, 2*w, 0);
}


@end
